package com.ruoyi.web.controller.customer;

import java.util.List;

import com.ruoyi.system.domain.customer.LocalReply;
import com.ruoyi.system.service.customer.LocalReplyService;
import io.swagger.models.auth.In;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.ws.rs.POST;

/**
 * 本地用户评论回复Controller
 * 
 * @author 张少丛
 * @date 2020-11-24
 */
@RestController
@RequestMapping("/customer/reply")
public class LocalReplyController extends BaseController
{
    @Autowired
    private LocalReplyService localReplyService;

    /**
     * 查询本地用户评论回复列表
     */
    @PreAuthorize("@ss.hasPermi('customer:reply:list')")
    @GetMapping("/list")
    public TableDataInfo list(LocalReply localReply)
    {
        startPage();
        List<LocalReply> list = localReplyService.selectLocalReplyList(localReply);
        return getDataTable(list);
    }

    /**
     * 导出本地用户评论回复列表
     */
    @PreAuthorize("@ss.hasPermi('customer:reply:export')")
    @Log(title = "本地用户评论回复", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LocalReply localReply)
    {
        List<LocalReply> list = localReplyService.selectLocalReplyList(localReply);
        ExcelUtil<LocalReply> util = new ExcelUtil<LocalReply>(LocalReply.class);
        return util.exportExcel(list, "reply");
    }

    /**
     * 获取本地用户评论回复详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:reply:query')")
    @GetMapping(value = "/{localReplyId}")
    public AjaxResult getInfo(@PathVariable("localReplyId") Long localReplyId)
    {
        return AjaxResult.success(localReplyService.selectLocalReplyById(localReplyId));
    }

    /**
     * 新增本地用户评论回复
     */
    @PreAuthorize("@ss.hasPermi('customer:reply:add')")
    @Log(title = "本地用户评论回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LocalReply localReply)
    {
        return toAjax(localReplyService.insertLocalReply(localReply));
    }

    /**
     * 修改本地用户评论回复
     */
    @PreAuthorize("@ss.hasPermi('customer:reply:edit')")
    @Log(title = "本地用户评论回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LocalReply localReply)
    {
        return toAjax(localReplyService.updateLocalReply(localReply));
    }

    /**
     * 删除本地用户评论回复
     */
    @PreAuthorize("@ss.hasPermi('customer:reply:remove')")
    @Log(title = "本地用户评论回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{localReplyIds}")
    public AjaxResult remove(@PathVariable Long[] localReplyIds)
    {
        return toAjax(localReplyService.deleteLocalReplyByIds(localReplyIds));
    }

}
